<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="${pageContext.request.contextPath}/statics/css/common.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/statics/css/style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div class="wrap">
<!-- main begin-->
  <div class="sale">
    <h1 class="lf">在线拍卖系统</h1>
    <c:if test="${not empty auctionUserSession}">
    	<div class="logout right"><a href="logout" title="注销">注销</a></div>
    </c:if>
    <c:if test="${empty auctionUserSession}">
    	<div class="logout right"><a href="${pageContext.request.contextPath}/login.jsp" title="登录">登录</a></div>
    </c:if>
  </div>
  <div class="items sg-font lf">
      <ul class="rows">
        <li>名称：</li>
        <li class="borderno">${auction.auctionName }</li>
      </ul>
      <ul class="rows">
        <li>描述：</li>
        <li class="borderno">${auction.auctionDesc }</li>
      </ul>
      <ul class="rows">
        <li>开始时间：</li>
        <li class="borderno"><fmt:formatDate value="${auction.auctionStartTime}" pattern="yyyy-MM-dd HH:mm:ss"/></li>
      </ul>
      <ul class="rows">
        <li>结束时间：</li>
        <li class="borderno"><fmt:formatDate value="${auction.auctionEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/></li>
      </ul>
      <ul class="rows border-no">
        <li>起拍价：</li>
        <li class="borderno">${auction.auctionStartPrice }</li>
      </ul>
  </div>
  <div class="rg borders"><img src="/imga/${auction.auctionPic }" width="270" alt="" /></div>
  <div class="cl"></div>
  <div class="top10 salebd">
  <form action="${pageContext.request.contextPath}/SaddRecord?auctionId=${auction.auctionId}&userId=${auctionUserSession.userId}" method="post">
       <p>
       <label for="sale">出价：</label>
       <input name="auctionPrice" type="text"  class="inputwd" id="sale" value=""/>
       <input type="submit" value="竞 拍" class="" id="jp" /><br>
       <span id="pd" style="color:red;"></span>
           <input type="hidden" value="${recordList[0].auctionPrice}" id="moneyMax">
           <input type="hidden" value="${recordList[0].userId}" id="userId2">
           <input type="hidden" value="${auctionUserSession.userId}" id="userId" name="userId">
           <input type="hidden" value="<fmt:formatDate value="${auction.auctionEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" id="end">
           <input type="hidden" value="<fmt:formatDate value="${auction.auctionStartTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" id="start">
           <input type="hidden" value="${auction.auctionId }" id="auctionId" name="auctionId">
           <input type="hidden" value="${auction.auctionStartPrice }" id="auctionStartPrice" name="auctionStartPrice">
       </p>
</form>
<%--<p class="f14 red">不能低于最高竞拍价</p>校验已在后台完成 --%>
       
  </div>
  <div class="top10">
      <input name="" type="button" value="刷 新" onclick="javascript:location.reload()" />
      <input name="" type="button" value="返回列表" class="" onclick="javascript:history.go(-1)"/>
  </div>
  <div class="offer">
    <h3>出价记录</h3>
    <div class="items sg-font">
    <c:if test="${auction.auctionRecords == 0}">
    	此拍卖品没有人竞拍
    </c:if>
     <c:if test="${auction.auctionRecords != 0}">
         <ul class="rows even strong">
	        <li>竞拍时间</li>
	        <li>竞拍价格</li>
	        <li class="borderno">竞拍人</li>
     	 </ul>
	    <c:forEach items="${recordList}" var="record" varStatus="status">
	      <ul class="rows" <c:if test="${status.index % 2 == 1}">style="background: #EBF6FA" </c:if>>
	        <li><fmt:formatDate value="${record.auctionTime}" pattern="yyyy-MM-dd HH:mm:ss"/></li>
	        <li>${record.auctionPrice }</li>
	        <li class="borderno">${record.userName }</li>
	      </ul>
	     </c:forEach>
	     </c:if>
  </div>
  </div>
<!-- main end-->
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
    $("#jp").on("click",function() {
        var end = $("#end").val();
        var start = $("#start").val()
        if(Date.parse(end) - new Date() <= 0){
            $("#pd").text("竞拍时间已经结束");
            return false;
        }else if(Date.parse(start) - new Date() >= 0){
            $("#pd").text("竞拍时间还未开始");
            return false;
        }else if ($("[name='auctionPrice']").val() == ''){
            $("#pd").text("竞拍价不能空");
            return false;
        }else if ($("[name='auctionPrice']").val() < parseFloat($("#auctionStartPrice").val())){
            $("#pd").text("竞拍价不能低于起拍价");
            return false;
        }else if ($("[name='auctionPrice']").val() < parseFloat($("#moneyMax").val())){
            $("#pd").text("不能低于最高竞拍价");
            return false;
        }else if ($("[name='auctionPrice']").val() < parseFloat($("#moneyMax").val()) + 100){
            $("#pd").text("您的竞拍价低于竞拍低价");
            return false;
        }else if ($("#userId").val() == $("#userId2").val()) {
            $("#pd").text("您已是目前最高价者");
            return false;
        }
    })
</script>
</body>
</html>
